<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-title">
          <h5><i class="fa fa-home"></i> 商品添加</h5>
          <div class="ibox-tools">
            <button type="button" class="btn btn-xs btn-primary btn-back-reply"><i class='fa fa-reply'></i> 返回</button>
          </div>
        </div>
        <div class="ibox-content">
          <form class="form-horizontal" method="post" action="#{$smarty.const.ACT}#/goods/Goods/goods_add/">
            <div class="tabs-container">
              <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 基本设置</a> </li>
                <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">商品详细</a> </li>
                <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">商品图片</a> </li>
                
                <li class=""><a data-toggle="tab" href="#tab-4" aria-expanded="false">商品规格</a> </li>
				     <li class=""><a data-toggle="tab" href="#tab-5" aria-expanded="false">商品属性</a> </li>
              </ul>
              <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                  <div class="panel-body">
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品名称：</label>
                      <div class="col-sm-10">
                        <input name="goods_name" class="form-control" type="text" placeholder="请输入商品的名称" required/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品分类：</label>
                      <div class="col-sm-10"> #{$goods_category_select}# </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品品牌：</label>
                      <div class="col-sm-8">
                        <input name="attr_name" class="form-control" type="text" placeholder="请输入属性类型名称" required/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品关键字：</label>
                      <div class="col-sm-10">
                        <input name="keywords" class="form-control" type="text" placeholder="请输入属性类型名称" required/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品简介：</label>
                      <div class="col-sm-10">
                        <textarea class="form-control" name="description"></textarea>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-12">购买信息：</label>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">市场价格：</label>
                      <div class="col-sm-10">
                        <input name="market_price" class="form-control" type="digits" value="#{$one.market_price}#" placeholder="商品市场价格"/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">销售价格：</label>
                      <div class="col-sm-10">
                        <input name="sale_price" class="form-control" type="digits" value="#{$one.sale_price}#" placeholder="商品销售价格"/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">成本价格：</label>
                      <div class="col-sm-10">
                        <input name="cost_price" class="form-control" type="digits" value="#{$one.cost_price}#" placeholder="商品成本价格"/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品库存：</label>
                      <div class="col-sm-10">
                        <input name="cost_price" class="form-control" type="digits" value="#{$one.stock}#" placeholder="商品成本价格"/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">商品排序：</label>
                      <div class="col-sm-8">
                        <input name="sort" class="form-control" type="digits" value="#{$one.sort}#" placeholder="排序号"/>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label">是否上架：</label>
                      <div class="col-sm-8">
                        <div class="checkbox i-checks">
                          <input type="checkbox" name="state" value="1" checked/>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
                <div id="tab-2" class="tab-pane">
                  <div class="panel-body"> 
                    <script id="container" name="content" type="text/plain" style="width:100%;height:200px;"></script> 
                  </div>
                </div>
                <div id="tab-3" class="tab-pane">
                  <div class="imgupload">
                    <div id="imglist" class="imglist"></div>
                    <div class="actbtn"> <img src="#{$smarty.const.APP}#/View/template/img/webuploader.png" onClick="javascript:imgupload('imglist');"> </div>
                  </div>
                </div>
                
                <div id="tab-4" class="tab-pane">
                  <div class="ibox-content"> <a class="btn btn-info btn-outline create_spec" href="javascript:void(0);">编辑规格</a> </div>
                  <div class="ibox-content"> 批量设置： <a href="javascript:void(0);" class="batch_modify_sale">销售价格</a>&nbsp;&nbsp; <a href="javascript:void(0);" class="batch_modify_market">市场价格</a> &nbsp;&nbsp; <a href="javascript:void(0);" class="batch_modify_cost">成本价格</a>&nbsp;&nbsp; <a href="javascript:void(0);" class="batch_modify_stock">库存</a> &nbsp;&nbsp; </div>
                  <div class="ibox-content" id="create_spec_show"></div>
                </div>
				  		<div id="tab-4" class="tab-pane">功能开发中。。。</div>
              </div>
            </div>
            <div class="panel-body">
              <div class="form-group">
                <div class="col-sm-offset-10 col-sm-2">
                  <button class="btn btn-w-m btn-info" type="submit">保存数据</button>
                </div>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script>
$(document).ready(function () {
	$('.i-checks').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
	});   

	var ue = UE.getEditor('container');
	ue.ready(function() {
		ue.setContent('#{$one.content}#');  //赋值给UEditor
	});
	//编辑规格
	$(".create_spec").click(function(){
		layer.open({
			type: 2,
			title: '规格创建',
			shadeClose: true,
			fixed: false, //不固定
			area: ['90%', '90%'],
			content: '#{$smarty.const.ACT}#/goods/GoodsSpec/goods_spec_create/create_id/create_spec_show/'//iframe的url
		});	
	});
	//批量设置插件
	layer.config({
		path: '#{$smarty.const.APP}#/View/template/js/plugins/layer/', //layer.js所在的目录，可以是绝对目录，也可以是相对目录
		extend: 'extend/layer.ext.js'
	});	
	$(".batch_modify_sale").click(function(){
		layer.prompt({
			title: '批量设置销售价格',
			formType: 0 //prompt风格，支持0-2
		}, function(data,index){
			$(".sku-table input[name='sku_sale_price[]']").val(data);
			layer.close(index);
		});
	});
	$(".batch_modify_market").click(function(){
		layer.prompt({
			title: '批量设置市场价格',
			formType: 0 //prompt风格，支持0-2
		}, function(data,index){
			$(".sku-table input[name='sku_market_price[]']").val(data);
			layer.close(index);
		});
	});
	$(".batch_modify_cost").click(function(){
		layer.prompt({
			title: '批量设置成本价格',
			formType: 0 //prompt风格，支持0-2
		}, function(data,index){
			$(".sku-table input[name='sku_cost_price[]']").val(data);
			layer.close(index);
		});
	});
	$(".batch_modify_stock").click(function(){
		layer.prompt({
			title: '批量设置库存',
			formType: 0 //prompt风格，支持0-2
		}, function(data,index){
			$(".sku-table input[name='sku_stock[]']").val(data);
			layer.close(index);
		});
	});
	
});
//绑定删除图片
$("body").on("click", ".imgupload_remove_img", function() {
	var li		=$(this).parent().parent();
	var imgfile	=$(this).attr('data-url');
	$.ajax({
		type: "GET",
		url: "#{$smarty.const.ACT}#/Upload/upload_img_remove/",
		data: {imgfile:imgfile},
		dataType: "json",
		success: function(data){
			if(data.rtnstatus=='success'){
				li.remove();
			}else{
				layer.msg(data.message, {icon: 5});
			}
		}
	});
	//li.remove();
});
//iframe层
function imgupload(imgs_id){
	layer.open({
		type: 2,
		title: '图片上传',
		shadeClose: true,
		fixed: false, //不固定
		area: ['90%', '90%'],
		content: '#{$smarty.const.ACT}#/Upload/upload_img/imgs_id/'+imgs_id //iframe的url
	});		
}
function imgupload_remove_img(obj,imgfile){
/*	$.ajax({
		type: "GET",
		url: "#{$smarty.const.ACT}#/Upload/upload_img_remove/",
		data: {imgfile:imgfile},
		dataType: "json",
		success: function(data){
			alert(data.rtnstatus);	
		}
	});*/
}
</script>
</body>
</html>
